﻿using System.Web.Mvc;
using MNH.Yarekoodak.DomainClasses;
using MNH.Yarekoodak.Services;
using MNH.Yarekoodak.Services.Authentication;
//using Ariyan.SakhtemanCo.WebApps.Models.User;

namespace MNH.Yarekoodak.WebApps.Controllers
{
    public class BaseController : Controller
    {
        #region Fields
        protected readonly IAuthenticationService _authenticationService = new FormsAuthenticationService();
        protected readonly User _user = null;
        //protected readonly PermissionManager _permissionManager = null;
        #endregion

        public BaseController()
        {
            _user = _authenticationService.GetAuthenticatedUser();
        }

        public void WarningNotification(string message)
        {
            if (!TempData.ContainsKey(Alerts.Warning))
                TempData.Add(Alerts.Warning, message);
            TempData[Alerts.Warning] = message;
        }

        public void SuccessNotification(string message)
        {
            if (!TempData.ContainsKey(Alerts.SUCCESS))
                TempData.Add(Alerts.SUCCESS, message);
            TempData[Alerts.SUCCESS] = message;
        }

        public void InformationNotification(string message)
        {
            if (!TempData.ContainsKey(Alerts.INFORMATION))
                TempData.Add(Alerts.INFORMATION, message);
            TempData[Alerts.INFORMATION] = message;
        }

        public void ErrorNotification(string message)
        {
            if (!TempData.ContainsKey(Alerts.ERROR))
                TempData.Add(Alerts.ERROR, message);
            TempData[Alerts.ERROR] = message;
        }
    }

    public static class Alerts
    {
        public const string SUCCESS = "success";
        public const string Warning = "warning";
        public const string ERROR = "danger";
        public const string INFORMATION = "info";

        public static string[] ALL
        {
            get { return new[] { SUCCESS, Warning, INFORMATION, ERROR }; }
        }
    }
}
